package com.hellobike.haxing.modules.wms.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hellobike.haxing.modules.wms.dto.WarehouseShopDto;
import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.wms.entity.WarehouseShop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: t_wms_warehouse_shop
 * @Author: haxing-boot
 * @Date:   2020-02-07
 * @Version: V1.0
 */
public interface WarehouseShopMapper extends BaseMapper<WarehouseShop> {

    @Select("<script>" +
            "SELECT s.id as shop_id,s.shop_name,s.mobile,wa.warehouse_name,w.warehouse_id FROM t_shop as s " +
            "LEFT JOIN t_wms_warehouse_shop as w ON w.shop_id=s.id " +
            "LEFT JOIN t_wms_warehouse as wa ON wa.id=w.warehouse_id where s.deleted = 0 " +
            "<if test='p.shopName != null and p.shopName != \"\"'>" +
            "AND s.shop_name LIKE '%${p.shopName}%' " +
            "</if>" +
            "<if test='p.mobile != null and p.mobile != \"\"'>" +
            "AND s.mobile LIKE '%${p.mobile}%' " +
            "</if>" +
            "<if test='p.warehouseName != null and p.warehouseName != \"\"'>" +
            "AND wa.warehouse_name LIKE '%${p.warehouseName}%' " +
            "</if>" +
            "<if test='p.isBind == 1 '>" +
            "AND wa.id is null  " +
            "</if>" +
            "<if test='p.isBind == 2 '>" +
            "AND wa.id is not null  " +
            "</if>" +
            "ORDER BY s.\"id\" DESC " +
            "</script>")
    IPage<WarehouseShopDto> pageByWarehouseShopDto(Page<WarehouseShopDto> page, @Param("p") WarehouseShopDto warehouseShop);
}
